from page.base_page import BasePage
from appium.webdriver.common.mobileby import By

class IndexPage(BasePage):
        #定位器
        # 好物社
        hws_locator = (By.XPATH, '//android.widget.TabWidget[@resource-id=\"android:id/tabs\"]/android.widget.RelativeLayout[4]/android.widget.RelativeLayout[1]/android.widget.ImageView[1]')
        #早餐
        zc_locator = (By.ID, 'com.gfeng.daydaycook:id/tv_breakfast')
        #紫薯
        djzs_locator = (By.XPATH,'//android.support.v7.widget.RecyclerView[@resource-id=\"com.gfeng.daydaycook:id/rv_daily\"]/android.widget.LinearLayout[1]')
        #+号
        jh_locator = (By.ID, 'com.gfeng.daydaycook:id/iv_add')
        #社区
        shequ_locator = (By.XPATH, "//android.widget.TabWidget[@resource-id=\"android:id/tabs\"]/android.widget.RelativeLayout[2]""/android.widget.RelativeLayout[1]")
        #我的
        wode_locator = (By.XPATH, "//android.widget.RelativeLayout/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]")
        spfl_locator = (By.XPATH, '//android.widget.TextView[@text=\"食谱分类\"]')
        # 获取文本
        hq_locator = (By.XPATH, '//android.widget.TextView[@text=\"每日菜单\"]')
        # 点击晒作品
        szp_locator = (By.XPATH, '//android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]')

        #操作方法
        #点击好物社
        def click_hws(self):
            self.driver.find_element(*self.hws_locator).click()
        #点击早餐
        def click_zc(self):
            self.driver.find_element(*self.zc_locator).click()
        #点击紫薯
        def click_djzs(self):
            self.driver.find_element(*self.djzs_locator).click()
        #点击+号
        def click_jh(self):
            self.driver.find_element(*self.jh_locator).click()
        #点击社区
        def click_shequ(self):
            self.driver.find_element(*self.shequ_locator).click()
        #我的
        def click_wode(self):
            self.driver.find_element(*self.wode_locator).click()

        # 点击食品分类
        def click_spfl(self):
            self.driver.find_element(*self.spfl_locator).click()

        # 获取文本
        def hq_text(self):
            self.driver.find_element(*self.hq_locator).get_attribute('text')

        # 点击晒作品
        def click_szp(self):
            self.driver.find_element(*self.szp_locator).click()